package DomainLayer;

public class Items
{
    private Product product;
    private int quantity;
    private int minimumAmount;
    private int maximumAmount;
    
    /**
     * @param product a product this company is selling.
     * @param quantity a number of product existing in the stock.
     * @param minimumAmount the lowest number of product the company can keep until reorder.
     * @param maximumAmount the highest number of product the company can have in the stock.
     */
    public Items(Product product, int quantity, int minimumAmount, int maximumAmount)
    {
        this.product = product;
        this.quantity = quantity;
        this.minimumAmount = minimumAmount;
        this.maximumAmount = maximumAmount;
    }
    
    //@returrn string an information about the item in the stock.
    public String toString(){
        return "ITEM INFORMATION: \n"+
                getProduct()+'\n'+
                "Quantity: "+getQuantity()+'\n'+
                "Minimum amount for product: "+getMinimumAmount()+'\n'+
                "Maximum amount for product: "+getMaximumAmount()+'\n';
    }
    
    public Product getProduct(){
        return product;
    }
    
    public void setProduct(Product product){
        this.product = product;
    }
    
    public void setQuantityt(int quantity){
        this.quantity = quantity;
    }
    
    public void setMaximumAmount(int maximumAmount){
        this.maximumAmount = maximumAmount;
    }
    
    public int getQuantity(){
        return quantity;
    }
    
    public void setMinimumAmount(int minimumAmount){
        this.minimumAmount = minimumAmount;
    }
    
    public int getMinimumAmount(){
        return minimumAmount;
    }
    
    public int getMaximumAmount(){
        return maximumAmount;
    }
    
    /**
     * @return true if you can add particular number of product into the stock.
     * @return false if its not possible
     */
    
    public boolean addNumberOfProduct(int number){
        if(quantity+number <= getMaximumAmount()){
            quantity+=number;
            return true;
        }else{
            return false;
        }
    }
    
    /**
     * @return true if you can substract particular number of product from the stock.
     * @return false if its not possible
     */
    public boolean substractNumberOfProduct(int number){
        if(quantity-number < 0){
            return false;
        }else{
            quantity-=number;
            return true;
        }
    }
}